package com.jlkf.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.jlkf.dao.TblCourseMapper;
import com.jlkf.dao.TblProblemMapper;
import com.jlkf.dao.TblProfessionInfoMapper;
import com.jlkf.dao.TblProfessionSortMapper;
import com.jlkf.dao.TblVipInfoMapper;
import com.jlkf.pojo.TblCourse;
import com.jlkf.pojo.TblProblem;
import com.jlkf.pojo.TblProfessionInfo;
import com.jlkf.pojo.TblProfessionSort;
import com.jlkf.pojo.TblVipInfo;
import com.jlkf.service.CourseManagerService;
import com.platform.server.response.response.pojo.ReturnData;

@Service
public class CourseManagerServiceImpl implements CourseManagerService {
	@Autowired
	private TblCourseMapper tblCourseMapper;
	@Autowired
	private TblProfessionSortMapper tblProfessionSortMapper;
	@Autowired
	private TblVipInfoMapper tblVipInfoMapper;
	@Autowired
	private TblProblemMapper tblProblemMapper;
	@Autowired
	private TblProfessionInfoMapper tblProfessionInfoMapper;
	
	/**
	 * 一般课程列表
	 */
	@Override
	public List<TblCourse> selectList(Map<String, Object> map) {
		// TODO Auto-generated method stub
		return tblCourseMapper.selectListByType(map);
	}

	/**
	 * 一般课程详情
	 */
	@Override
	public TblCourse selectDetail(Long gId) {
		// TODO Auto-generated method stub
		return tblCourseMapper.selectDetail(gId);
	}

	/**
	 * 一般课程设置折扣
	 */
	@Override
	public int updateDiscount(Map<String, Object> map) {
		// TODO Auto-generated method stub
		return tblCourseMapper.updateDiscount(map);
	}

    /**
     * 职业方向、知识体系、特色课程列表
     */
	@Override
	public List<TblProfessionSort> selectOtherList(Map<String, Object> map) {
		// TODO Auto-generated method stub
		return tblProfessionSortMapper.selectByType(map);
	}

	/**
	 * 职业方向、知识体系、特色课程设置折扣 
	 */
	@Override
	public int updateOtherDiscount(Map<String, Object> map) {
		// TODO Auto-generated method stub
		return tblProfessionSortMapper.updateDiscount(map);
	}

	/**
	 * 职业方向、知识体系、特色课程详情
	 */
	@Override
	public TblProfessionSort selectOtherDetail(Integer gId) {
		// TODO Auto-generated method stub
		return tblProfessionSortMapper.selectByPrimaryKey(gId);
	}

	/**
	 * 会员折扣列表
	 */
	@Override
	public List<TblVipInfo> vipList() {
		// TODO Auto-generated method stub
		return tblVipInfoMapper.selectVipList();
	}

	/**
	 * 修改会员折扣
	 */
	@Override
	public int updateVipDiscount(TblVipInfo vipInfo) {
		// TODO Auto-generated method stub
		return tblVipInfoMapper.updateDiscount(vipInfo);
	}

	/**
	 * 会员信息详情
	 * */
	@Override
	public TblVipInfo selectVipDetail(Long gId) {
		// TODO Auto-generated method stub
		return tblVipInfoMapper.selectByPrimaryKey(gId.toString());
	}

	/**
	 * 课程提问列表
	 */
	@Override
	public List<TblProblem> getProblemList(String courseName) {
		// TODO Auto-generated method stub
		return tblProblemMapper.selectList(courseName);
	}

	/**
	 * 置顶
	 * @param courseId
	 * @return
	 */
	@Override
	public ReturnData toTop(Long gId) {
		int maxNumber = tblProblemMapper.maxNumber();
		Map<String, Object> map  = new HashMap<>();
		map.put("gId", gId);
		map.put("num", maxNumber+1);
		int top = tblProblemMapper.toTop(map);
		if(top>0){
		    return new ReturnData(200,"置顶成功"); 
		}
		return new ReturnData(2010,"置顶失败");
	}

	/**
	 * 删除提问
	 */
	@Override
	public int deleteProblem(Long gId) {
		// TODO Auto-generated method stub
		return tblProblemMapper.deleteByPrimaryKey(gId);
	}
	
	@Override
	public int updateIsShow(Map<String, Object> map) {
		// TODO Auto-generated method stub
		return tblProblemMapper.updateIsShow(map);
	}

	@Override
	public TblProblem getDetail(Long gId) {
		// TODO Auto-generated method stub
		return tblProblemMapper.selectDetail(gId);
	}

	@Override
	public int updateProblem(TblProblem problem) {
		// TODO Auto-generated method stub
		return tblProblemMapper.updateByPrimaryKeySelective(problem);
	}

	@Override
	public List<TblProfessionInfo> getInfoList() {
		// TODO Auto-generated method stub
		return tblProfessionInfoMapper.selectList();
	}

	@Override
	public TblProfessionInfo getInfoDetail(Integer gId) {
		// TODO Auto-generated method stub
		return tblProfessionInfoMapper.selectByPrimaryKey(gId);
	}

	@Override
	public int deleteInfo(Integer gId) {
		// TODO Auto-generated method stub
		return tblProfessionInfoMapper.deleteByPrimaryKey(gId);
	}

	@Override
	public int update(TblProfessionInfo info) {
		// TODO Auto-generated method stub
		return tblProfessionInfoMapper.updateByPrimaryKeySelective(info);
	}

	@Override
	public int insert(TblProfessionInfo info) {
		// TODO Auto-generated method stub
		return tblProfessionInfoMapper.insertSelective(info);
	}

}
